<?php
xmlwriter_start_element($xml,"forum");
$query = "select * from forum_posts order by `time` desc limit 5";
$result = mysql_query($query);
if ($result) {
	while ($post = mysql_fetch_array($result)) {
		$query2 = "select * from `forum_threads` where `id`='".$post['parent']."'";
		$result2 = mysql_query($query2);
		if ($result2) {
			$thread = mysql_fetch_array($result2);
			$query3 = "select `time` from `forum_posts` where `id` ='".$post['id']."'";
			$result3 = mysql_query($query3);
			$post2 = mysql_fetch_array($result3);
			$time = date("d-m-Y H:i:s",$post2['time']);
			$title = GetLangString($lang,"forum_title".$thread['parent']) ;
			$query4 = "select * from `users` where `id` = '".$post['user']."'";
			$result4 = mysql_query($query4);
			$userinfo = mysql_fetch_array($result4);
			$poster = $userinfo['name'];

    	xmlwriter_start_element($xml,"post");

      xmlwriter_write_element($xml,"threadname",	  $thread['name'] );	
      xmlwriter_write_element($xml,"threadid",	    $thread['id'] );
      xmlwriter_write_element($xml,"timestamp",	    $post2['time'] );
      xmlwriter_write_element($xml,"timeformatted",	$time);
      xmlwriter_write_element($xml,"poster",	      $userinfo['name'] );
      xmlwriter_write_element($xml,"url",	          $SITE_URL."/index.php?do=forum&thread=".$post['parent'] );

      xmlwriter_end_element($xml);
		} 
	}
} 
xmlwriter_end_element($xml);
?>
